<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>访问本地文件系统</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="wrappers.html">« 支持的协议和封装协议</a></li>
      <li style="float: right;"><a href="wrappers.http.html">http:// »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="wrappers.html">支持的协议和封装协议</a></li>
    <li>访问本地文件系统</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="wrappers.file" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">file://</h1>
  <p class="refpurpose"><span class="refname">file://</span> &mdash; <span class="dc-title">访问本地文件系统</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-wrappers.file-description">
  <h3 class="title">说明</h3>
  <p class="para">
   <em class="emphasis">文件系统</em> 是 PHP 使用的默认封装协议，展现了本地文件系统。
   当指定了一个相对路径（不以/、\、\\或 Windows 盘符开头的路径）提供的路径将基于当前的工作目录。
   在很多情况下是脚本所在的目录，除非被修改了。
   使用 CLI 的时候，目录默认是脚本被调用时所在的目录。
  </p>
  <p class="simpara">
   在某些函数里，例如 <span class="function"><a href="function.fopen.html" class="function">fopen()</a></span> 和 <span class="function"><a href="function.file-get-contents.html" class="function">file_get_contents()</a></span>，
   <code class="literal">include_path</code> 会可选地搜索，也作为相对的路径。
  </p>
 </div>


 <div class="refsect1 usage" id="refsect1-wrappers.file-usage"> 
  <h3 class="title">用法</h3>
  <ul class="itemizedlist">
   <li class="listitem"><span class="simpara"><var class="filename">/path/to/file.ext</var></span></li>
   <li class="listitem"><span class="simpara"><var class="filename">relative/path/to/file.ext</var></span></li>
   <li class="listitem"><span class="simpara"><var class="filename">fileInCwd.ext</var></span></li>
   <li class="listitem"><span class="simpara"><var class="filename">C:/path/to/winfile.ext</var></span></li>
   <li class="listitem"><span class="simpara"><var class="filename">C:\path\to\winfile.ext</var></span></li>
   <li class="listitem"><span class="simpara"><var class="filename">\\smbserver\share\path\to\winfile.ext</var></span></li>
   <li class="listitem"><span class="simpara"><var class="filename">file:///path/to/file.ext</var></span></li>
  </ul>
 </div>
 

 <div class="refsect1 options" id="refsect1-wrappers.file-options">
  <h3 class="title">可选项</h3>
  <p class="para">
   <table class="doctable table">
    <caption><strong>封装协议概要</strong></caption>
    
     <thead>
      <tr>
       <th>属性</th>
       <th>支持</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>受 <a href="filesystem.configuration.html#ini.allow-url-fopen" class="link">allow_url_fopen</a> 影响</td>
       <td>No</td>
      </tr>

      <tr>
       <td>允许读取</td>
       <td>Yes</td>
      </tr>

      <tr>
       <td>允许写入</td>
       <td>Yes</td>
      </tr>

      <tr>
       <td>允许添加</td>
       <td>Yes</td>
      </tr>

      <tr>
       <td>允许同时读和写</td>
       <td>Yes</td>
      </tr>

      <tr>
       <td>支持 <span class="function"><a href="function.stat.html" class="function">stat()</a></span></td>
       <td>Yes</td>
      </tr>

      <tr>
       <td>支持 <span class="function"><a href="function.unlink.html" class="function">unlink()</a></span></td>
       <td>Yes</td>
      </tr>

      <tr>
       <td>支持 <span class="function"><a href="function.rename.html" class="function">rename()</a></span></td>
       <td>Yes</td>
      </tr>

      <tr>
       <td>支持 <span class="function"><a href="function.mkdir.html" class="function">mkdir()</a></span></td>
       <td>Yes</td>
      </tr>

      <tr>
       <td>支持 <span class="function"><a href="function.rmdir.html" class="function">rmdir()</a></span></td>
       <td>Yes</td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>
 

</div></div></div></body></html>